package main

import (
	"net/http"
)

type Version struct {
	ClientVer string
	ServerVer string
}

func (a *Version) SetVersion(w http.ResponseWriter, r *http.Request) {
	cli := r.FormValue("client")
	srv := r.FormValue("server")
	if cli == "" || srv == "" {
		w.WriteHeader(404)
		w.Write([]byte("request parameters error\n"))
		return
	}

	a.ClientVer = cli
	a.ServerVer = srv
	w.Write([]byte("set version success\n"))
	return
}

func (a *Version) CheckUpdate(w http.ResponseWriter, r *http.Request) {
	w.WriteHeader(200)
	w.Write([]byte(a.ClientVer))
}
